var app = getApp();
Page({
  data: {
    message: [],
    tid: "",
    phase_time: "",
    price: "",
    state: "",
    tequan: [], //特权
  },
  onLoad: function(e) {
    var that = this;
    //查询套餐
    var openid = wx.getStorageSync("openid");
    wx.request({
      url: 'https://www.mamingwang.cn/api/index/package',
      data: {
        openid: openid
      },
      method: "post",
      success(res) {
        console.log(res)
        that.setData({
          message: res.data.message,
          xinxi: res.data.data,
          e: e.zid ? e.zid : ""
        })
      }
    });
    //查询特权
    wx.request({
      url: 'https://www.mamingwang.cn/api/index/privilege',
      data: {
        openid: openid
      },
      method: "post",
      success(res) {
        that.setData({
          tequan: res.data.message,
        })
      }
    })
  },
  //选择套餐
  chooseTaoCan: function(e) {
    console.log(e)
    this.setData({
      tid: e.currentTarget.dataset.tid,
      phase_time: e.currentTarget.dataset.phase_time,
      price: e.currentTarget.dataset.price,
      state: e.currentTarget.dataset.state
    })
  },
  //跳转到支付详情页面
  goPayMoney: function() {
    if (this.data.tid == "") {
      wx.showToast({
        title: '请选择一种套餐',
        icon: "none",
        duration: 2000,
        mask:true
      })
    } else {
      wx.navigateTo({
        url: "../renZheng/renZheng?tid=" + this.data.tid + "&phase_time=" + this.data.phase_time + "&price=" + this.data.price + "&state=" + this.data.state + "&zid=" + this.data.e,
      })
    }
  }
})